import BaseController from "../../cfw/mvc/BaseController";
import ModuleManager, { ModuleID } from "../../cfw/module/ModuleManager";
import SDKManager from "../../sdk/SDKManager";
import LoadingController from "../loading/LoadingController";
import LobbyController from "../lobby/LobbyController";
import UIManager from "../../cfw/ui/UIManager";


export default class CrazyClickC extends BaseController {


    private static ins: CrazyClickC;

    static instance() {
        if (!this.ins) {
            this.ins = new CrazyClickC()
        }
        return this.ins;
    }

    static step: number = 0;

    // protected witch: number = 0;



    gotoLayer(func?: Function) {
        this.callback = func;
        // this.witch = w;
        let hasSubPackage = SDKManager.getChannel().hasSubPackage()
        if (hasSubPackage) {
            ModuleManager.loadBundle(ModuleID.CRAZY_CLICK, () => {
                this.intoLayer()
            })
        } else {
            this.intoLayer()
        }
    }
    protected callback: Function;
    intoLayer() {
        // ModuleManager.setModuleID(ModuleID.CRAZY_CLICK)
        this.pushView('prefabs/crazyClick/CrazyClickView', 'CrazyClickView', null, ModuleManager.getLoader(ModuleID.CRAZY_CLICK))
    }




    next() {
        // console.log(' this.witch ', this.witch)
        if (this.callback) {
            this.callback();
            this.callback = null;
        }
        // if (this.witch == 0) {
        //     this.gotoLobby()
        // } else {
        // }

    }
    gotoLobby() {
        UIManager.instance().clear()
        let hasSubPackage = SDKManager.getChannel().hasSubPackage()
        if (hasSubPackage) {
            LoadingController.instance().intoLayer(ModuleID.LOBBY, [ModuleID.LOBBY, ModuleID.DECORATION, ModuleID.SMALL_GAME])
        } else {
            LobbyController.instance().intoLayer()
        }



    }
}
